import Vue from 'vue'
import App from './App'
import router from './router'
import elementUI from 'element-ui'
import iView from 'iview'
import store from '@/store/store'
import 'element-ui/lib/theme-chalk/index.css'
import echarts from 'echarts'
import {locale, DatePicker, Upload} from 'iview'
Vue.use(elementUI, { size: 'mini' })
import VueQuillEditor from 'vue-quill-editor'
import 'quill/dist/quill.core.css'
import 'quill/dist/quill.snow.css'
import 'quill/dist/quill.bubble.css'
// import 'babel-polyfill'

Vue.config.productionTip = false
Vue.prototype.$echarts = echarts

// vue 使用 地区插件 
import  VueAreaLinkage from 'vue-area-linkage'
Vue.use(VueAreaLinkage);
Vue.use(iView);

import { pca, pcaa } from 'area-data'; 
import 'vue-area-linkage/dist/index.css'
Vue.prototype.$pca = pca;
Vue.prototype.$pcaa = pcaa;
import   '@/assets/css/base.css';

// 注册一个全局守卫，作用是在路由跳转前，对路由进行判断，防止未登录的用户跳转到其他需要登录的页面去
router.beforeEach((to, from, next) => {
    let token = sessionStorage.getItem('mytoken')
    // 如果已经登录，那我不干涉你，让你随便访问
    if (token) {
        next()
    } else {
        if (to.path !== '/login') {
          // 如果没有登录，但你访问其他需要登录的页面，那我就让你跳到登录页面去
          next({path: '/login'})
        } else {
          // 如果没有登录，但你访问的login，那就不干涉你，让你访问
          next()
        }
    }
})

/* eslint-disable no-new */
new Vue({
  el: '#app',
  store,
  router,
  render: h => h(App)
})
